package service

import (
	"fmt"
	_ "github.com/mattn/go-sqlite3"
	"os"
	"xorm.io/xorm"
)

var Engine *xorm.Engine

func init() {
	engine, err := xorm.NewEngine("sqlite3", "afupanel.db")
	if err != nil {
		os.Exit(-1)
	}
	Engine = engine
	err = Engine.Sync(
		new(Setting),
		new(User),
		new(Session),
	)
	if err != nil {
		fmt.Println(err.Error())
	}
	AddDefaultSettings()
	AddDefaultUser()
}
